#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <ctime>

#include "kahansum.h"
#include "LinearClassifier.h"
#include "median.h"
#include "Vector.h"
#include "utils.h"
#include "kmeans.h"
#include "MLP.h"
#include "SangerRule.h"
using namespace std;

int main2()
{
	vector<DMVector> vlist;
	vector<int> vp;
	int i, j;
	srand( (unsigned)time( NULL ) );

	vlist = read_data ( "dataset-4", vp );
	
	LinearClassifier linear(vlist[0].size(), 0.3);
	int max, size, index;
	size = vlist.size();
	max = (int)(vlist.size() * 0.8);
	i = 0;
	linear.reset();
	
	vector<double> vmean = vector_mean ( vlist );
	int sj = vlist[0].size();
	for ( i = 0; i < size; ++i )
	{
		for ( j = 0; j < sj; ++j )
		{
			vlist[i].set ( j, vlist[i].get ( j ) - vmean[j] );
		}
	}
	
	i = 0;
	while ( i < 512 )
	{
		index = rand() % max;
		linear.update_weights ( vlist[index], vp[index] == 1 ? true : false );
		i++;
	}
	
	for ( i = 0; i < size; ++i )
	{
		if ( linear.classify ( vlist[i] ) == true )
			vp[i] = 1;
		else 
			vp[i] = 0;
	}
	
	write_data ( "out-3-2-1", vlist, vp );

	return 0;

}

